package com.stu.entity.permission;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.stu.entity.base.BaseEntity;

@Entity
@Table(name = "PERMISSIONMENU_ROOT")
public class PermissionMenuRoot extends BaseEntity  {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String cname;
	private String description;
	private Integer orderNo;
	private String icon;
	private List<PermissionMenu> menus = new ArrayList<PermissionMenu>();

	public PermissionMenuRoot() {

	}
	
	public PermissionMenuRoot(String uuid){
		super(uuid);
	}

	@Column(name = "cname", length = 50)
	public String getCname() {
		return cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}

	@Column(name = "description", length = 255)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "orderno")
	public Integer getOrderNo() {
		if(orderNo==null)
			return 0;
		return orderNo;
	}

	public void setOrderNo(Integer orderNo) {
		this.orderNo = orderNo;
	}

	@Column(name = "icon", length = 255)
	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	@OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinColumn(name = "root")
	/*@Where(clause="USE_FLAG='Y'")*/
	//@OrderBy(value = "orderno asc")
	public List<PermissionMenu> getMenus() {
		return menus;
	}

	public void setMenus(List<PermissionMenu> menus) {
		this.menus = menus;
	}

}
